package com.qst.financing.service.impl;

import com.qst.financing.dao.BankUserDao;
import com.qst.financing.entity.BankUser;
import com.qst.financing.service.BankUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BankUserServiceImpl implements BankUserService {
    @Autowired
    private BankUserDao bankUserDao;

    @Value("${bank.bankid}")
    private Integer bankid;

    @Override
    public List<BankUser> selectAllBankUser(Integer bankid) {
        List<BankUser> bankUsers = bankUserDao.selectAllBankUser(bankid);
        return bankUsers;
    }

    @Override
    public BankUser selectByUserName(String userName) {
        BankUser bankUser = bankUserDao.selectByPrimaryKey(userName, bankid);
        return bankUser;
    }

    @Override
    public void update(BankUser bankUser) {
        bankUserDao.updateByPrimaryKeySelective(bankUser);
    }

    @Override
    public void add(BankUser bankUser) {
        bankUserDao.insertSelective(bankUser);
    }

    @Override
    public void delete(String userName) {
        bankUserDao.deleteByPrimaryKey(userName);
    }
}
